<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />




<title>Hierarchical model for molecular clock</title>

<script src="site_libs/jquery-1.11.3/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="site_libs/bootstrap-3.3.5/css/cosmo.min.css" rel="stylesheet" />
<script src="site_libs/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/respond.min.js"></script>
<script src="site_libs/navigation-1.1/tabsets.js"></script>
<link href="site_libs/highlightjs-9.12.0/textmate.css" rel="stylesheet" />
<script src="site_libs/highlightjs-9.12.0/highlight.js"></script>
<script src="site_libs/kePrint-0.0.1/kePrint.js"></script>
<link href="site_libs/font-awesome-5.1.0/css/all.css" rel="stylesheet" />
<link href="site_libs/font-awesome-5.1.0/css/v4-shims.css" rel="stylesheet" />

<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
  pre:not([class]) {
    background-color: white;
  }
</style>
<script type="text/javascript">
if (window.hljs) {
  hljs.configure({languages: []});
  hljs.initHighlightingOnLoad();
  if (document.readyState && document.readyState === "complete") {
    window.setTimeout(function() { hljs.initHighlighting(); }, 0);
  }
}
</script>



<style type="text/css">
h1 {
  font-size: 34px;
}
h1.title {
  font-size: 38px;
}
h2 {
  font-size: 30px;
}
h3 {
  font-size: 24px;
}
h4 {
  font-size: 18px;
}
h5 {
  font-size: 16px;
}
h6 {
  font-size: 12px;
}
.table th:not([align]) {
  text-align: left;
}
</style>




<style type = "text/css">
.main-container {
  max-width: 940px;
  margin-left: auto;
  margin-right: auto;
}
code {
  color: inherit;
  background-color: rgba(0, 0, 0, 0.04);
}
img {
  max-width:100%;
}
.tabbed-pane {
  padding-top: 12px;
}
.html-widget {
  margin-bottom: 20px;
}
button.code-folding-btn:focus {
  outline: none;
}
summary {
  display: list-item;
}
</style>


<style type="text/css">
/* padding for bootstrap navbar */
body {
  padding-top: 51px;
  padding-bottom: 40px;
}
/* offset scroll position for anchor links (for fixed navbar)  */
.section h1 {
  padding-top: 56px;
  margin-top: -56px;
}
.section h2 {
  padding-top: 56px;
  margin-top: -56px;
}
.section h3 {
  padding-top: 56px;
  margin-top: -56px;
}
.section h4 {
  padding-top: 56px;
  margin-top: -56px;
}
.section h5 {
  padding-top: 56px;
  margin-top: -56px;
}
.section h6 {
  padding-top: 56px;
  margin-top: -56px;
}
.dropdown-submenu {
  position: relative;
}
.dropdown-submenu>.dropdown-menu {
  top: 0;
  left: 100%;
  margin-top: -6px;
  margin-left: -1px;
  border-radius: 0 6px 6px 6px;
}
.dropdown-submenu:hover>.dropdown-menu {
  display: block;
}
.dropdown-submenu>a:after {
  display: block;
  content: " ";
  float: right;
  width: 0;
  height: 0;
  border-color: transparent;
  border-style: solid;
  border-width: 5px 0 5px 5px;
  border-left-color: #cccccc;
  margin-top: 5px;
  margin-right: -10px;
}
.dropdown-submenu:hover>a:after {
  border-left-color: #ffffff;
}
.dropdown-submenu.pull-left {
  float: none;
}
.dropdown-submenu.pull-left>.dropdown-menu {
  left: -100%;
  margin-left: 10px;
  border-radius: 6px 0 6px 6px;
}
</style>

<script>
// manage active state of menu based on current page
$(document).ready(function () {
  // active menu anchor
  href = window.location.pathname
  href = href.substr(href.lastIndexOf('/') + 1)
  if (href === "")
    href = "index.html";
  var menuAnchor = $('a[href="' + href + '"]');

  // mark it active
  menuAnchor.parent().addClass('active');

  // if it's got a parent navbar menu mark it active as well
  menuAnchor.closest('li.dropdown').addClass('active');
});
</script>

<!-- tabsets -->

<style type="text/css">
.tabset-dropdown > .nav-tabs {
  display: inline-table;
  max-height: 500px;
  min-height: 44px;
  overflow-y: auto;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.tabset-dropdown > .nav-tabs > li.active:before {
  content: "";
  font-family: 'Glyphicons Halflings';
  display: inline-block;
  padding: 10px;
  border-right: 1px solid #ddd;
}

.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
  content: "&#xe258;";
  border: none;
}

.tabset-dropdown > .nav-tabs.nav-tabs-open:before {
  content: "";
  font-family: 'Glyphicons Halflings';
  display: inline-block;
  padding: 10px;
  border-right: 1px solid #ddd;
}

.tabset-dropdown > .nav-tabs > li.active {
  display: block;
}

.tabset-dropdown > .nav-tabs > li > a,
.tabset-dropdown > .nav-tabs > li > a:focus,
.tabset-dropdown > .nav-tabs > li > a:hover {
  border: none;
  display: inline-block;
  border-radius: 4px;
}

.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
  display: block;
  float: none;
}

.tabset-dropdown > .nav-tabs > li {
  display: none;
}
</style>

<!-- code folding -->




</head>

<body>


<div class="container-fluid main-container">




<div class="navbar navbar-default  navbar-fixed-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="index.html">ipmn-pdac-timing</a>
    </div>
    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        <li>
  <a href="index.html">Home</a>
</li>
<li>
  <a href="about.html">About</a>
</li>
<li>
  <a href="license.html">License</a>
</li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li>
  <a href="https://gitlab.com/rscharpf/ipmn-timing">
    <span class="fa fa-gitlab"></span>
     
    Source code
  </a>
</li>
      </ul>
    </div><!--/.nav-collapse -->
  </div><!--/.container -->
</div><!--/.navbar -->

<!-- Add a small amount of space between sections. -->
<style type="text/css">
div.section {
  padding-top: 12px;
}
</style>

<div class="fluid-row" id="header">



<h1 class="title toc-ignore">Hierarchical model for molecular clock</h1>

</div>


<p>
<button type="button" class="btn btn-default btn-workflowr btn-workflowr-report" data-toggle="collapse" data-target="#workflowr-report">
<span class="glyphicon glyphicon-list" aria-hidden="true"></span> workflowr <span class="glyphicon glyphicon-ok text-success" aria-hidden="true"></span>
</button>
</p>
<div id="workflowr-report" class="collapse">
<ul class="nav nav-tabs">
<li class="active">
<a data-toggle="tab" href="#summary">Summary</a>
</li>
<li>
<a data-toggle="tab" href="#checks"> Checks <span class="glyphicon glyphicon-ok text-success" aria-hidden="true"></span> </a>
</li>
<li>
<a data-toggle="tab" href="#versions">Past versions</a>
</li>
</ul>
<div class="tab-content">
<div id="summary" class="tab-pane fade in active">
<p>
<strong>Last updated:</strong> 2019-08-28
</p>
<p>
<strong>Checks:</strong> <span class="glyphicon glyphicon-ok text-success" aria-hidden="true"></span> 7 <span class="glyphicon glyphicon-exclamation-sign text-danger" aria-hidden="true"></span> 0
</p>
<p>
<strong>Knit directory:</strong> <code>ipmn-timing/</code> <span class="glyphicon glyphicon-question-sign" aria-hidden="true" title="This is the local directory in which the code in this file was executed."> </span>
</p>
<p>
This reproducible <a href="http://rmarkdown.rstudio.com">R Markdown</a> analysis was created with <a
  href="https://github.com/jdblischak/workflowr">workflowr</a> (version 1.4.0.9000). The <em>Checks</em> tab describes the reproducibility checks that were applied when the results were created. The <em>Past versions</em> tab lists the development history.
</p>
<hr>
</div>
<div id="checks" class="tab-pane fade">
<div id="workflowr-checks" class="panel-group">
<div class="panel panel-default">
<div class="panel-heading">
<p class="panel-title">
<a data-toggle="collapse" data-parent="#workflowr-checks" href="#strongRMarkdownfilestronguptodate"> <span class="glyphicon glyphicon-ok text-success" aria-hidden="true"></span> <strong>R Markdown file:</strong> up-to-date </a>
</p>
</div>
<div id="strongRMarkdownfilestronguptodate" class="panel-collapse collapse">
<div class="panel-body">
<p>Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.</p>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<p class="panel-title">
<a data-toggle="collapse" data-parent="#workflowr-checks" href="#strongEnvironmentstrongempty"> <span class="glyphicon glyphicon-ok text-success" aria-hidden="true"></span> <strong>Environment:</strong> empty </a>
</p>
</div>
<div id="strongEnvironmentstrongempty" class="panel-collapse collapse">
<div class="panel-body">
<p>Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.</p>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<p class="panel-title">
<a data-toggle="collapse" data-parent="#workflowr-checks" href="#strongSeedstrongcodesetseed20190724code"> <span class="glyphicon glyphicon-ok text-success" aria-hidden="true"></span> <strong>Seed:</strong> <code>set.seed(20190724)</code> </a>
</p>
</div>
<div id="strongSeedstrongcodesetseed20190724code" class="panel-collapse collapse">
<div class="panel-body">
<p>The command <code>set.seed(20190724)</code> was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.</p>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<p class="panel-title">
<a data-toggle="collapse" data-parent="#workflowr-checks" href="#strongSessioninformationstrongrecorded"> <span class="glyphicon glyphicon-ok text-success" aria-hidden="true"></span> <strong>Session information:</strong> recorded </a>
</p>
</div>
<div id="strongSessioninformationstrongrecorded" class="panel-collapse collapse">
<div class="panel-body">
<p>Great job! Recording the operating system, R version, and package versions is critical for reproducibility.</p>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<p class="panel-title">
<a data-toggle="collapse" data-parent="#workflowr-checks" href="#strongCachestrongnone"> <span class="glyphicon glyphicon-ok text-success" aria-hidden="true"></span> <strong>Cache:</strong> none </a>
</p>
</div>
<div id="strongCachestrongnone" class="panel-collapse collapse">
<div class="panel-body">
<p>Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.</p>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<p class="panel-title">
<a data-toggle="collapse" data-parent="#workflowr-checks" href="#strongFilepathsstrongrelative"> <span class="glyphicon glyphicon-ok text-success" aria-hidden="true"></span> <strong>File paths:</strong> relative </a>
</p>
</div>
<div id="strongFilepathsstrongrelative" class="panel-collapse collapse">
<div class="panel-body">
<p>Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.</p>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<p class="panel-title">
<a data-toggle="collapse" data-parent="#workflowr-checks" href="#strongRepositoryversionstrongahrefhttpsgitlabcomrscharpfipmntimingtreea32dbed797e83eb45f85a7ac2bad6a52c75309a0targetblanka32dbeda"> <span class="glyphicon glyphicon-ok text-success" aria-hidden="true"></span> <strong>Repository version:</strong> <a href="https://gitlab.com/rscharpf/ipmn-timing/tree/a32dbed797e83eb45f85a7ac2bad6a52c75309a0" target="_blank">a32dbed</a> </a>
</p>
</div>
<div id="strongRepositoryversionstrongahrefhttpsgitlabcomrscharpfipmntimingtreea32dbed797e83eb45f85a7ac2bad6a52c75309a0targetblanka32dbeda" class="panel-collapse collapse">
<div class="panel-body">
<p>
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility. The version displayed above was the version of the Git repository at the time these results were generated. <br><br> Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use <code>wflow_publish</code> or <code>wflow_git_commit</code>). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
</p>
<pre><code>
Ignored files:
    Ignored:    analysis/.Rhistory
    Ignored:    code/clock.R
    Ignored:    data/~$Timing_Metrics.xlsx
    Ignored:    publish.R

</code></pre>
<p>
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
</p>
</div>
</div>
</div>
</div>
<hr>
</div>
<div id="versions" class="tab-pane fade">

<p>
These are the previous versions of the R Markdown and HTML files. If you’ve configured a remote Git repository (see <code>?wflow_git_remote</code>), click on the hyperlinks in the table below to view them.
</p>
<div class="table-responsive">
<table class="table table-condensed table-hover">
<thead>
<tr>
<th>
File
</th>
<th>
Version
</th>
<th>
Author
</th>
<th>
Date
</th>
<th>
Message
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
html
</td>
<td>
<a href="https://glcdn.githack.com/rscharpf/ipmn-timing/raw/a32dbed797e83eb45f85a7ac2bad6a52c75309a0/public/timing_hierarchical.html" target="_blank">a32dbed</a>
</td>
<td>
rscharpf
</td>
<td>
2019-08-28
</td>
<td>
Host with GitLab.
</td>
</tr>
<tr>
<td>
Rmd
</td>
<td>
<a href="https://gitlab.com/rscharpf/ipmn-timing/blob/290ade5ede503aeb7d342e5c87921398b289e199/analysis/timing_hierarchical.Rmd" target="_blank">290ade5</a>
</td>
<td>
rscharpf
</td>
<td>
2019-08-28
</td>
<td>
wflow_publish(c(“analysis/timing_hierarchical.Rmd”,
</td>
</tr>
</tbody>
</table>
</div>
<hr>
</div>
</div>
</div>
<div id="read-data" class="section level1">
<h1>Read data</h1>
<pre class="r"><code>library(rjags)
library(tidyverse)
library(ggmcmc)
library(kableExtra)
library(magrittr)
library(readxl)
unixFriendly &lt;- function(x){
  x &lt;- colnames(x)
  x &lt;- tolower(x)
  x &lt;- gsub(&quot; &quot;, &quot;_&quot;, x)
  x
}
dat &lt;- read_excel(file.path(&quot;data&quot;,
                            &quot;Timing_Metrics.xlsx&quot;),
                  sheet=2) %&gt;%
  &quot;[&quot;(-nrow(.), ) %&gt;%
  set_colnames(unixFriendly(.)) %&gt;%
  mutate(additional=mutations_ca-mutations_hg_ipmn) %&gt;%
  filter(case != &quot;MTP19&quot;)
dat</code></pre>
<pre><code># A tibble: 17 x 4
   case  mutations_hg_ipmn mutations_ca additional
   &lt;chr&gt;             &lt;dbl&gt;        &lt;dbl&gt;      &lt;dbl&gt;
 1 MTP1                 41           56         15
 2 MTP2                 72          108         36
 3 MTP3                 26           31          5
 4 MTP4                 57           65          8
 5 MTP5                 33           49         16
 6 MTP6                 51           61         10
 7 MTP7                 72           73          1
 8 MTP8                 34           77         43
 9 MTP9                 30           37          7
10 MTP11                73           75          2
11 MTP13                23           29          6
12 MTP14                51           88         37
13 MTP18                47           63         16
14 MTP23                24           68         44
15 MTP24                39           41          2
16 MTP26                56           64          8
17 MTP30                32           43         11</code></pre>
</div>
<div id="inferential-models" class="section level1">
<h1>Inferential models</h1>
<p>Our sampling model for the number of additional mutations acquired in PDAC sample <span class="math inline">\(i\)</span> is Poisson with mean <span class="math inline">\(\theta_i\)</span>. Assuming the mutation rate <span class="math inline">\(\mu\)</span> can be estimated from previous studies from the ages of patients with PDAC and HG IPMNs discovered incidentally, we factor the average number of mutations <span class="math inline">\(\theta_i\)</span> as the product of the mutation rate <span class="math inline">\(\mu\)</span> (assumed to be the same for all patients) and number of years <span class="math inline">\(T_i\)</span> during which the <span class="math inline">\(y_i\)</span> mutations accumulated. The second stage of the model posits a Gamma sampling distribution for the timing between the birth of the HG IPMN and the PDAC. Finally, we use diffuse priors for the shape and rate parameters of the Gamma. The model implemented in JAGS version 4.3.0 is</p>
<p><span class="math display">\[\begin{align*}
y_i &amp;\sim \text{Poisson}(\theta_i)\\
\theta_i &amp;= \mu T_i \\
T_i &amp;\sim \text{Gamma}(a, b)\\
a &amp;= 1 + m * b \\
b &amp;= \frac{m + \sqrt{m^2 + 4*s^2}}{2s^2}\\
m &amp;\sim \text{Uniform}(0, 100) \\
s &amp;\sim \text{Uniform}(0, 100),
\end{align*}\]</span> where <span class="math inline">\(m\)</span> and <span class="math inline">\(s\)</span> correspond to the mode and standard deviation of the gamma prior for <span class="math inline">\(T\)</span>. We implemented this model under three different assumptions for <span class="math inline">\(\mu\)</span>.</p>
</div>
<div id="previous-studies" class="section level1">
<h1>Previous studies</h1>
<p>We calculated the difference of the mean age of patients with PDACs in two studies (studies weighted by size of study) and the mean age of 14 patients where HG IPMNs were discovered incidentally:</p>
<pre class="r"><code>ipmn.age &lt;- read_excel(file.path(&quot;data&quot;,
                                 &quot;Timing_Metrics.xlsx&quot;),
                       sheet=1) %&gt;%
  &quot;[&quot;(1:2, ) %&gt;%
  set_colnames(c(&quot;age&quot;, &quot;n&quot;, &quot;url&quot;)) %&gt;%
  mutate(age=as.numeric(age),
         n=as.integer(n))
ipmn.age</code></pre>
<pre><code># A tibble: 2 x 3
    age     n url                                
  &lt;dbl&gt; &lt;int&gt; &lt;chr&gt;                              
1  67.3   395 https://paperpile.com/shared/lqfd4v
2  62      14 https://paperpile.com/shared/GBCNVM</code></pre>
<pre class="r"><code>ipmn.age2 &lt;- ipmn.age[2, ]
pdac.age &lt;- read_excel(file.path(&quot;data&quot;,
                                 &quot;Timing_Metrics.xlsx&quot;),
                       sheet=1) %&gt;%
  &quot;[&quot;(5:6, ) %&gt;%
  set_colnames(c(&quot;age&quot;, &quot;n&quot;, &quot;url&quot;)) %&gt;%
  mutate(age=as.numeric(age),
         n=as.integer(n))
pdac.age</code></pre>
<pre><code># A tibble: 2 x 3
    age     n url                                
  &lt;dbl&gt; &lt;int&gt; &lt;chr&gt;                              
1  70     183 https://paperpile.com/shared/8AktOz
2  68.1    52 https://paperpile.com/shared/B7pWq9</code></pre>
<pre class="r"><code>Tavg &lt;- pdac.age$age[2] - ipmn.age2$age
round(Tavg, 1)</code></pre>
<pre><code>[1] 6.1</code></pre>
<p>To estimate the mutation rate, we assume that (1) the HG IPMN and PDAC speciments from the patients in these studies would have a similar number of mutations that were observed in our study and (2) that the average time during which these mutations occurred in these historical patients can be estimated by the mean difference in the average ages of the patients between these two studies. The distribution of the number of additional mutations acquired in the PDAC samples in our study is bimodal with modes at approximately 40 and 8, suggesting that the rates may be heterogenous. Our first estimate for the mutation rate, <span class="math inline">\(\mu_1\)</span>, is 15.5/5, or <span class="math inline">\(\approx\)</span> 3.1. To examine the sensitivity of posterior inference to our assumption about the mutation rate, we repeated the analysis using <span class="math inline">\(\mu_2 = 15.5/4\)</span> (4 years difference in ages) and <span class="math inline">\(\mu_3 = 15.5/2\)</span> (2 years difference in ages).</p>
<pre class="r"><code>mu1 &lt;- round(15.5/5, 2)
mu2 &lt;- round(15.5/4, 2)
mu3 &lt;- round(15.5/2, 2)</code></pre>
<div id="model-1-3.1-mutationsyear" class="section level2">
<h2>Model 1: 3.1 mutations/year</h2>
<pre class="r"><code>y &lt;- dat$additional
m1 &lt;- jags.model(file.path(&quot;code&quot;, &quot;clock.jag&quot;),
                data=list(y=y, N = length(y), mu=mu1),
                inits=list(T=rep(5, length(y))),
                n.adapt = 2000, n.chains = 3)
jags_samples &lt;- coda.samples(m1,
                             variable.names=&quot;T&quot;,
                             n.iter=2000)
jags_df &lt;- ggs(jags_samples)
##ggs_traceplot(jags_df)
summaries.mu1 &lt;- jags_df %&gt;%
  &quot;[&quot;(grep(&quot;T&quot;, .$Parameter), ) %&gt;%
  group_by(Parameter) %&gt;%
  summarize(lower=quantile(value, 0.05),
            median=quantile(value, 0.5),
            mean=mean(value),
            upper=quantile(value, 0.95)) %&gt;%
  mutate(mu=mu1)</code></pre>
</div>
<div id="model-2-3.88-mutationsyear" class="section level2">
<h2>Model 2: 3.88 mutations/year</h2>
<pre class="r"><code>m2 &lt;- jags.model(file.path(&quot;code&quot;, &quot;clock.jag&quot;),
                data=list(y=y, N = length(y), mu=mu2),
                inits=list(T=rep(5, length(y))),
                n.adapt = 2000, n.chains = 3)
jags_samples &lt;- coda.samples(m2,
                             variable.names=&quot;T&quot;,
                             n.iter=2000)
jags_df &lt;- ggs(jags_samples)
summaries.mu2 &lt;- jags_df %&gt;%
  &quot;[&quot;(grep(&quot;T&quot;, .$Parameter), ) %&gt;%
  group_by(Parameter) %&gt;%
  summarize(lower=quantile(value, 0.05),
            median=quantile(value, 0.5),
            mean=mean(value),
            upper=quantile(value, 0.95)) %&gt;%
  mutate(mu=mu2)</code></pre>
</div>
<div id="model-3-7.75-mutationsyear" class="section level2">
<h2>Model 3: 7.75 mutations/year</h2>
<pre class="r"><code>m3 &lt;- jags.model(file.path(&quot;code&quot;, &quot;clock.jag&quot;),
                data=list(y=y, N = length(y), mu=mu3),
                inits=list(T=rep(5, length(y))),
                n.adapt = 2000, n.chains = 3)
jags_samples &lt;- coda.samples(m3,
                             variable.names=&quot;T&quot;,
                             n.iter=2000)
jags_df &lt;- ggs(jags_samples)
summaries.mu3 &lt;- jags_df %&gt;%
  &quot;[&quot;(grep(&quot;T&quot;, .$Parameter), ) %&gt;%
  group_by(Parameter) %&gt;%
  summarize(lower=quantile(value, 0.05),
            median=quantile(value, 0.5),
            mean=mean(value),
            upper=quantile(value, 0.95)) %&gt;%
  mutate(mu=mu3)</code></pre>
</div>
<div id="posterior-summaries" class="section level2">
<h2>Posterior summaries</h2>
<pre class="r"><code>summaries &lt;- list(summaries.mu1,
                  summaries.mu2,
                  summaries.mu3) %&gt;%
  do.call(rbind, .) %&gt;%
  mutate(id=rep(dat$case, 3),
         id=factor(id, levels=dat$case))
mus &lt;- rep(paste(c(mu1, mu2, mu3), &quot;mutations/year&quot;), each=nrow(dat)) %&gt;%
  factor(., levels=unique(.))</code></pre>
<div id="timing-estimates-faceted-by-assumed-mutation-rate" class="section level3">
<h3>Timing estimates faceted by assumed mutation rate</h3>
<div class="figure" style="text-align: center">
<img src="figure/timing_hierarchical.Rmd/facet_by_mutationrate-1.png" alt="90% posterior credible intervals" width="864" />
<p class="caption">
90% posterior credible intervals
</p>
</div>
<p>
<button type="button" class="btn btn-default btn-xs btn-workflowr btn-workflowr-fig" data-toggle="collapse" data-target="#fig-facet_by_mutationrate-1">
Past versions of facet_by_mutationrate-1.png
</button>
</p>
<div id="fig-facet_by_mutationrate-1" class="collapse">
<div class="table-responsive">
<table class="table table-condensed table-hover">
<thead>
<tr>
<th>
Version
</th>
<th>
Author
</th>
<th>
Date
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="https://gitlab.com/rscharpf/ipmn-timing/blob/a32dbed797e83eb45f85a7ac2bad6a52c75309a0/public/figure/timing_hierarchical.Rmd/facet_by_mutationrate-1.png" target="_blank">a32dbed</a>
</td>
<td>
rscharpf
</td>
<td>
2019-08-28
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div id="timing-estimates-faceted-by-sample-id" class="section level3">
<h3>Timing estimates faceted by sample id</h3>
<div class="figure" style="text-align: center">
<img src="figure/timing_hierarchical.Rmd/facet_by_id-1.png" alt="90% posterior credible intervals" width="768" />
<p class="caption">
90% posterior credible intervals
</p>
</div>
<p>
<button type="button" class="btn btn-default btn-xs btn-workflowr btn-workflowr-fig" data-toggle="collapse" data-target="#fig-facet_by_id-1">
Past versions of facet_by_id-1.png
</button>
</p>
<div id="fig-facet_by_id-1" class="collapse">
<div class="table-responsive">
<table class="table table-condensed table-hover">
<thead>
<tr>
<th>
Version
</th>
<th>
Author
</th>
<th>
Date
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="https://gitlab.com/rscharpf/ipmn-timing/blob/a32dbed797e83eb45f85a7ac2bad6a52c75309a0/public/figure/timing_hierarchical.Rmd/facet_by_id-1.png" target="_blank">a32dbed</a>
</td>
<td>
rscharpf
</td>
<td>
2019-08-28
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div id="overall-differences" class="section level3">
<h3>Overall differences</h3>
<p>The posterior distributions for the modal <span class="math inline">\(m\)</span> and the standard deviation <span class="math inline">\(s\)</span> of the gamma density for each of the above models can be used to describe the mean modal time to progression and the heterogeneity in this population, respectively.</p>
</div>
<div id="tabled-values" class="section level3">
<h3>Tabled values</h3>
<table class="table table-striped table-hover table-condensed" style="width: auto !important; margin-left: auto; margin-right: auto;">
<thead>
<tr>
<th style="text-align:left;">
Id
</th>
<th style="text-align:right;">
Lower (years)
</th>
<th style="text-align:right;">
Median (years)
</th>
<th style="text-align:right;">
Mean (years)
</th>
<th style="text-align:right;">
Upper (years)
</th>
<th style="text-align:right;">
Mutations/year
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;">
MTP1
</td>
<td style="text-align:right;">
3.09
</td>
<td style="text-align:right;">
4.77
</td>
<td style="text-align:right;">
4.89
</td>
<td style="text-align:right;">
7.03
</td>
<td style="text-align:right;">
3.10
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP2
</td>
<td style="text-align:right;">
8.27
</td>
<td style="text-align:right;">
11.06
</td>
<td style="text-align:right;">
11.15
</td>
<td style="text-align:right;">
14.38
</td>
<td style="text-align:right;">
3.10
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP3
</td>
<td style="text-align:right;">
0.86
</td>
<td style="text-align:right;">
1.82
</td>
<td style="text-align:right;">
1.92
</td>
<td style="text-align:right;">
3.34
</td>
<td style="text-align:right;">
3.10
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP4
</td>
<td style="text-align:right;">
1.47
</td>
<td style="text-align:right;">
2.70
</td>
<td style="text-align:right;">
2.80
</td>
<td style="text-align:right;">
4.48
</td>
<td style="text-align:right;">
3.10
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP5
</td>
<td style="text-align:right;">
3.31
</td>
<td style="text-align:right;">
5.09
</td>
<td style="text-align:right;">
5.19
</td>
<td style="text-align:right;">
7.39
</td>
<td style="text-align:right;">
3.10
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP6
</td>
<td style="text-align:right;">
1.95
</td>
<td style="text-align:right;">
3.32
</td>
<td style="text-align:right;">
3.42
</td>
<td style="text-align:right;">
5.23
</td>
<td style="text-align:right;">
3.10
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP7
</td>
<td style="text-align:right;">
0.15
</td>
<td style="text-align:right;">
0.62
</td>
<td style="text-align:right;">
0.72
</td>
<td style="text-align:right;">
1.64
</td>
<td style="text-align:right;">
3.10
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP8
</td>
<td style="text-align:right;">
10.20
</td>
<td style="text-align:right;">
13.23
</td>
<td style="text-align:right;">
13.29
</td>
<td style="text-align:right;">
16.74
</td>
<td style="text-align:right;">
3.10
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP9
</td>
<td style="text-align:right;">
1.25
</td>
<td style="text-align:right;">
2.40
</td>
<td style="text-align:right;">
2.49
</td>
<td style="text-align:right;">
4.04
</td>
<td style="text-align:right;">
3.10
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP11
</td>
<td style="text-align:right;">
0.29
</td>
<td style="text-align:right;">
0.91
</td>
<td style="text-align:right;">
1.01
</td>
<td style="text-align:right;">
2.06
</td>
<td style="text-align:right;">
3.10
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP13
</td>
<td style="text-align:right;">
1.05
</td>
<td style="text-align:right;">
2.10
</td>
<td style="text-align:right;">
2.19
</td>
<td style="text-align:right;">
3.69
</td>
<td style="text-align:right;">
3.10
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP14
</td>
<td style="text-align:right;">
8.61
</td>
<td style="text-align:right;">
11.34
</td>
<td style="text-align:right;">
11.49
</td>
<td style="text-align:right;">
14.68
</td>
<td style="text-align:right;">
3.10
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP18
</td>
<td style="text-align:right;">
3.31
</td>
<td style="text-align:right;">
5.05
</td>
<td style="text-align:right;">
5.17
</td>
<td style="text-align:right;">
7.33
</td>
<td style="text-align:right;">
3.10
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP23
</td>
<td style="text-align:right;">
10.35
</td>
<td style="text-align:right;">
13.43
</td>
<td style="text-align:right;">
13.51
</td>
<td style="text-align:right;">
16.96
</td>
<td style="text-align:right;">
3.10
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP24
</td>
<td style="text-align:right;">
0.30
</td>
<td style="text-align:right;">
0.89
</td>
<td style="text-align:right;">
1.00
</td>
<td style="text-align:right;">
2.10
</td>
<td style="text-align:right;">
3.10
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP26
</td>
<td style="text-align:right;">
1.47
</td>
<td style="text-align:right;">
2.68
</td>
<td style="text-align:right;">
2.79
</td>
<td style="text-align:right;">
4.48
</td>
<td style="text-align:right;">
3.10
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP30
</td>
<td style="text-align:right;">
2.15
</td>
<td style="text-align:right;">
3.61
</td>
<td style="text-align:right;">
3.70
</td>
<td style="text-align:right;">
5.59
</td>
<td style="text-align:right;">
3.10
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP1
</td>
<td style="text-align:right;">
2.49
</td>
<td style="text-align:right;">
3.82
</td>
<td style="text-align:right;">
3.90
</td>
<td style="text-align:right;">
5.60
</td>
<td style="text-align:right;">
3.88
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP2
</td>
<td style="text-align:right;">
6.69
</td>
<td style="text-align:right;">
8.85
</td>
<td style="text-align:right;">
8.95
</td>
<td style="text-align:right;">
11.52
</td>
<td style="text-align:right;">
3.88
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP3
</td>
<td style="text-align:right;">
0.68
</td>
<td style="text-align:right;">
1.45
</td>
<td style="text-align:right;">
1.54
</td>
<td style="text-align:right;">
2.66
</td>
<td style="text-align:right;">
3.88
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP4
</td>
<td style="text-align:right;">
1.19
</td>
<td style="text-align:right;">
2.15
</td>
<td style="text-align:right;">
2.23
</td>
<td style="text-align:right;">
3.55
</td>
<td style="text-align:right;">
3.88
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP5
</td>
<td style="text-align:right;">
2.66
</td>
<td style="text-align:right;">
4.07
</td>
<td style="text-align:right;">
4.15
</td>
<td style="text-align:right;">
5.98
</td>
<td style="text-align:right;">
3.88
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP6
</td>
<td style="text-align:right;">
1.54
</td>
<td style="text-align:right;">
2.65
</td>
<td style="text-align:right;">
2.72
</td>
<td style="text-align:right;">
4.14
</td>
<td style="text-align:right;">
3.88
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP7
</td>
<td style="text-align:right;">
0.12
</td>
<td style="text-align:right;">
0.49
</td>
<td style="text-align:right;">
0.57
</td>
<td style="text-align:right;">
1.32
</td>
<td style="text-align:right;">
3.88
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP8
</td>
<td style="text-align:right;">
8.09
</td>
<td style="text-align:right;">
10.51
</td>
<td style="text-align:right;">
10.59
</td>
<td style="text-align:right;">
13.38
</td>
<td style="text-align:right;">
3.88
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP9
</td>
<td style="text-align:right;">
1.03
</td>
<td style="text-align:right;">
1.91
</td>
<td style="text-align:right;">
2.00
</td>
<td style="text-align:right;">
3.26
</td>
<td style="text-align:right;">
3.88
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP11
</td>
<td style="text-align:right;">
0.23
</td>
<td style="text-align:right;">
0.73
</td>
<td style="text-align:right;">
0.80
</td>
<td style="text-align:right;">
1.63
</td>
<td style="text-align:right;">
3.88
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP13
</td>
<td style="text-align:right;">
0.85
</td>
<td style="text-align:right;">
1.69
</td>
<td style="text-align:right;">
1.77
</td>
<td style="text-align:right;">
2.98
</td>
<td style="text-align:right;">
3.88
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP14
</td>
<td style="text-align:right;">
6.91
</td>
<td style="text-align:right;">
9.06
</td>
<td style="text-align:right;">
9.17
</td>
<td style="text-align:right;">
11.72
</td>
<td style="text-align:right;">
3.88
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP18
</td>
<td style="text-align:right;">
2.65
</td>
<td style="text-align:right;">
4.06
</td>
<td style="text-align:right;">
4.15
</td>
<td style="text-align:right;">
5.95
</td>
<td style="text-align:right;">
3.88
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP23
</td>
<td style="text-align:right;">
8.28
</td>
<td style="text-align:right;">
10.75
</td>
<td style="text-align:right;">
10.84
</td>
<td style="text-align:right;">
13.65
</td>
<td style="text-align:right;">
3.88
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP24
</td>
<td style="text-align:right;">
0.24
</td>
<td style="text-align:right;">
0.74
</td>
<td style="text-align:right;">
0.82
</td>
<td style="text-align:right;">
1.66
</td>
<td style="text-align:right;">
3.88
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP26
</td>
<td style="text-align:right;">
1.19
</td>
<td style="text-align:right;">
2.17
</td>
<td style="text-align:right;">
2.24
</td>
<td style="text-align:right;">
3.56
</td>
<td style="text-align:right;">
3.88
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP30
</td>
<td style="text-align:right;">
1.71
</td>
<td style="text-align:right;">
2.86
</td>
<td style="text-align:right;">
2.94
</td>
<td style="text-align:right;">
4.45
</td>
<td style="text-align:right;">
3.88
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP1
</td>
<td style="text-align:right;">
1.24
</td>
<td style="text-align:right;">
1.92
</td>
<td style="text-align:right;">
1.96
</td>
<td style="text-align:right;">
2.81
</td>
<td style="text-align:right;">
7.75
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP2
</td>
<td style="text-align:right;">
3.35
</td>
<td style="text-align:right;">
4.42
</td>
<td style="text-align:right;">
4.47
</td>
<td style="text-align:right;">
5.75
</td>
<td style="text-align:right;">
7.75
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP3
</td>
<td style="text-align:right;">
0.34
</td>
<td style="text-align:right;">
0.71
</td>
<td style="text-align:right;">
0.76
</td>
<td style="text-align:right;">
1.31
</td>
<td style="text-align:right;">
7.75
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP4
</td>
<td style="text-align:right;">
0.59
</td>
<td style="text-align:right;">
1.07
</td>
<td style="text-align:right;">
1.12
</td>
<td style="text-align:right;">
1.81
</td>
<td style="text-align:right;">
7.75
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP5
</td>
<td style="text-align:right;">
1.33
</td>
<td style="text-align:right;">
2.03
</td>
<td style="text-align:right;">
2.07
</td>
<td style="text-align:right;">
2.97
</td>
<td style="text-align:right;">
7.75
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP6
</td>
<td style="text-align:right;">
0.77
</td>
<td style="text-align:right;">
1.32
</td>
<td style="text-align:right;">
1.35
</td>
<td style="text-align:right;">
2.07
</td>
<td style="text-align:right;">
7.75
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP7
</td>
<td style="text-align:right;">
0.06
</td>
<td style="text-align:right;">
0.24
</td>
<td style="text-align:right;">
0.29
</td>
<td style="text-align:right;">
0.64
</td>
<td style="text-align:right;">
7.75
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP8
</td>
<td style="text-align:right;">
4.07
</td>
<td style="text-align:right;">
5.27
</td>
<td style="text-align:right;">
5.31
</td>
<td style="text-align:right;">
6.67
</td>
<td style="text-align:right;">
7.75
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP9
</td>
<td style="text-align:right;">
0.50
</td>
<td style="text-align:right;">
0.96
</td>
<td style="text-align:right;">
1.00
</td>
<td style="text-align:right;">
1.66
</td>
<td style="text-align:right;">
7.75
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP11
</td>
<td style="text-align:right;">
0.11
</td>
<td style="text-align:right;">
0.36
</td>
<td style="text-align:right;">
0.40
</td>
<td style="text-align:right;">
0.83
</td>
<td style="text-align:right;">
7.75
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP13
</td>
<td style="text-align:right;">
0.41
</td>
<td style="text-align:right;">
0.84
</td>
<td style="text-align:right;">
0.88
</td>
<td style="text-align:right;">
1.48
</td>
<td style="text-align:right;">
7.75
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP14
</td>
<td style="text-align:right;">
3.43
</td>
<td style="text-align:right;">
4.53
</td>
<td style="text-align:right;">
4.58
</td>
<td style="text-align:right;">
5.83
</td>
<td style="text-align:right;">
7.75
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP18
</td>
<td style="text-align:right;">
1.32
</td>
<td style="text-align:right;">
2.05
</td>
<td style="text-align:right;">
2.09
</td>
<td style="text-align:right;">
2.98
</td>
<td style="text-align:right;">
7.75
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP23
</td>
<td style="text-align:right;">
4.16
</td>
<td style="text-align:right;">
5.40
</td>
<td style="text-align:right;">
5.43
</td>
<td style="text-align:right;">
6.84
</td>
<td style="text-align:right;">
7.75
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP24
</td>
<td style="text-align:right;">
0.12
</td>
<td style="text-align:right;">
0.37
</td>
<td style="text-align:right;">
0.41
</td>
<td style="text-align:right;">
0.82
</td>
<td style="text-align:right;">
7.75
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP26
</td>
<td style="text-align:right;">
0.59
</td>
<td style="text-align:right;">
1.07
</td>
<td style="text-align:right;">
1.11
</td>
<td style="text-align:right;">
1.77
</td>
<td style="text-align:right;">
7.75
</td>
</tr>
<tr>
<td style="text-align:left;">
MTP30
</td>
<td style="text-align:right;">
0.85
</td>
<td style="text-align:right;">
1.44
</td>
<td style="text-align:right;">
1.48
</td>
<td style="text-align:right;">
2.22
</td>
<td style="text-align:right;">
7.75
</td>
</tr>
</tbody>
</table>
<br>
<p>
<button type="button" class="btn btn-default btn-workflowr btn-workflowr-sessioninfo" data-toggle="collapse" data-target="#workflowr-sessioninfo" style="display: block;">
<span class="glyphicon glyphicon-wrench" aria-hidden="true"></span> Session information
</button>
</p>
<div id="workflowr-sessioninfo" class="collapse">
<pre class="r"><code>sessionInfo()</code></pre>
<pre><code>R version 3.6.0 (2019-04-26)
Platform: x86_64-apple-darwin18.5.0/x86_64 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS:   /Users/rscharpf/Rversions/R-3.6.0/lib/x86_64/libRblas.dylib
LAPACK: /Users/rscharpf/Rversions/R-3.6.0/lib/x86_64/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] readxl_1.3.1     magrittr_1.5     kableExtra_1.1.0 ggmcmc_1.3      
 [5] forcats_0.4.0    stringr_1.4.0    dplyr_0.8.3      purrr_0.3.2     
 [9] readr_1.3.1      tidyr_0.8.3      tibble_2.1.3     ggplot2_3.2.1   
[13] tidyverse_1.2.1  rjags_4-9        coda_0.19-3     

loaded via a namespace (and not attached):
 [1] tidyselect_0.2.5     xfun_0.9             haven_2.1.1         
 [4] lattice_0.20-38      colorspace_1.4-1     generics_0.0.2      
 [7] vctrs_0.2.0          viridisLite_0.3.0    htmltools_0.3.6     
[10] yaml_2.2.0           utf8_1.1.4           rlang_0.4.0         
[13] pillar_1.4.2         withr_2.1.2          glue_1.3.1          
[16] RColorBrewer_1.1-2   modelr_0.1.5         plyr_1.8.4          
[19] munsell_0.5.0        gtable_0.3.0         workflowr_1.4.0.9000
[22] cellranger_1.1.0     rvest_0.3.4          evaluate_0.14       
[25] labeling_0.3         GGally_1.4.0         knitr_1.24          
[28] fansi_0.4.0          highr_0.8            broom_0.5.2         
[31] Rcpp_1.0.2           backports_1.1.4      scales_1.0.0        
[34] webshot_0.5.1        jsonlite_1.6         fs_1.3.1            
[37] hms_0.5.1            digest_0.6.20        stringi_1.4.3       
[40] grid_3.6.0           rprojroot_1.3-2      cli_1.1.0           
[43] tools_3.6.0          lazyeval_0.2.2       crayon_1.3.4        
[46] whisker_0.3-2        pkgconfig_2.0.2      zeallot_0.1.0       
[49] xml2_1.2.2           lubridate_1.7.4      reshape_0.8.8       
[52] assertthat_0.2.1     rmarkdown_1.15       httr_1.4.1          
[55] rstudioapi_0.10      R6_2.4.0             nlme_3.1-141        
[58] git2r_0.26.1         compiler_3.6.0      </code></pre>
</div>
</div>
</div>
</div>


<!-- Adjust MathJax settings so that all math formulae are shown using
TeX fonts only; see
http://docs.mathjax.org/en/latest/configuration.html.  This will make
the presentation more consistent at the cost of the webpage sometimes
taking slightly longer to load. Note that this only works because the
footer is added to webpages before the MathJax javascript. -->
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    "HTML-CSS": { availableFonts: ["TeX"] }
  });
</script>



</div>

<script>

// add bootstrap table styles to pandoc tables
function bootstrapStylePandocTables() {
  $('tr.header').parent('thead').parent('table').addClass('table table-condensed');
}
$(document).ready(function () {
  bootstrapStylePandocTables();
});


</script>

<!-- tabsets -->

<script>
$(document).ready(function () {
  window.buildTabsets("TOC");
});

$(document).ready(function () {
  $('.tabset-dropdown > .nav-tabs > li').click(function () {
    $(this).parent().toggleClass('nav-tabs-open')
  });
});
</script>

<!-- code folding -->


<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
  (function () {
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src  = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
    document.getElementsByTagName("head")[0].appendChild(script);
  })();
</script>

</body>
</html>
